package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.bean.CompanyWorkTimeDetail;
import com.hengxinguotong.zhihuichengjian.treeview.RecyclerAdapter;
import com.hengxinguotong.zhihuichengjian.widget.font.HXTextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @CopyRight 恒信国通信息科技
 * @Author WuLei
 * @Date 2019/4/4
 * <p>
 * 工时明细
 */

public class WorkTimeDetailAdapter extends RecyclerAdapter<CompanyWorkTimeDetail, WorkTimeDetailAdapter.WorkTimeDetailViewHolder> {

    public WorkTimeDetailAdapter(Context context, List<CompanyWorkTimeDetail> dataList) {
        super(context, dataList);
    }

    @Override
    public WorkTimeDetailViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_attendance_company_work_time_detail, null);
        return new WorkTimeDetailViewHolder(view);
    }

    @Override
    public void onBindViewHolder(WorkTimeDetailViewHolder holder, int position) {
        holder.bindData(position);
    }

    public class WorkTimeDetailViewHolder extends RecyclerAdapter.BaseViewHolder<CompanyWorkTimeDetail> {
        @BindView(R.id.company_name)
        HXTextView companyName;
        @BindView(R.id.team_name)
        HXTextView teamName;
        @BindView(R.id.work_time)
        HXTextView workTime;
        @BindView(R.id.attendance_person_number)
        HXTextView attendancePersonNumber;
        @BindView(R.id.create_time_tv)
        HXTextView createTimeTv;

        public WorkTimeDetailViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void bindData(int position) {
            final CompanyWorkTimeDetail companyWorkTimeDetail = dataList.get(position);
            companyName.setText(companyWorkTimeDetail.getCompanyName());
            teamName.setText(companyWorkTimeDetail.getTeamName());
            workTime.setText("日总工时：" + companyWorkTimeDetail.getTime() + "小时");
            attendancePersonNumber.setText("出勤人数：" + companyWorkTimeDetail.getCount() + "人");
            createTimeTv.setText(companyWorkTimeDetail.getDate());
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onClickListener.onClick(companyWorkTimeDetail);
                }
            });
        }
    }
}
